package org.correct.util;

/**
 * This is a synchronized Counter tool.
 * 
 * @author Li Yujia
 *
 */
public class Counter {
	private int counter;
	
	public Counter() {
		counter = 0;
	}
	
	/**
	 * Increase the counter by one and return the value after increasing.
	 * 
	 * @return The value of the counter after increasing.
	 */
	public synchronized int inc() {
		return (++counter);
	}
	
	/**
	 * Decrease the counter by one and return the value after decreasing.
	 * 
	 * @return The value of the counter after decreasing.
	 */
	public synchronized int dec() {
		return (--counter);
	}
	
	public synchronized int val() {
		return counter;
	}
}
